'##############
'Cockpit-Script
'Приборная панель, кабина и салон
'##############

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhдngenden Funktionen

'(c) 23.10.2009 Rьdiger Hьlsmann
'(c) 15.04.2010 Marcel Kuhnt

'Script Version: 1.0
'Omsi release: 1.0

'Needs:
'- antrieb
'- engine
'- bremse
'- lights
'- wiper?
'- doors


'Revision History:
'- Rьdiger Hьlsmann	09.06.2009	Last Change				
'- Marcel Kuhnt		13.06.2009	Added Gearbox switches			
'- Marcel Kuhnt		13.06.2009	Moved some switchvars to other scripts	
'- Rьdiger Hьlsmann	19.06.2009	Added Openable Window Triggers
'- Rьdiger Hьlsmann	23.10.2009	Added Battery and kinderwagen light
'- Marcel Kuhnt		26.10.2009	Radio switchable with Motorkьhlung (replaced with cassette player)
'- Rьdiger Hьlsmann	28.10.2009	Added driver door
'- Rьdiger Hьlsmann	16.12.2009	Added driver curtain
'- Rьdiger Hьlsmann	18.12.2009	Bugfix driver curtain
'- Marcel Kuhnt		15.04.2010	Traegheit debugged
'- Rьdiger Hьlsmann	13.05.2010	Engine temperature
'- Rьdiger Hьlsmann	03.06.2010	Automatic battery switch on key insertion (For standard-II-buses)
'- Rьdiger Hьlsmann	08.06.2010	Automatic battery switch made optional, Auxiliary heating switchable by button or switch
'- Rьdiger Hьlsmann	23.06.2010	Added mouse-clickable wiper lever on wheel console
'- Rьdiger Hьlsmann	08.07.2010	Wiper lever: Improved usability 
'- Rьdiger Hьlsmann	18.07.2010	Wiper lever: soundfix for keyboard operation and new ignition key algorithm 
'- Rьdiger Hьlsmann	16.09.2010	Auxheat Switch Bugfix
'- Rьdiger Hьlsmann	18.09.2010	Imported microphone switch
'- Rьdiger Hьlsmann	17.10.2010	Added pressure warning needle
'- Rьdiger Hьlsmann	23.10.2010	Added old-style gear button functionality
'- Rьdiger Hьlsmann	06.11.2010	Gear-button "1" functionality removed for old-style gear buttons
'- Rьdiger Hьlsmann	16.11.2010	Heating sliders
'- Rьdiger Hьlsmann	23.11.2010	Central lubrication, cabin heater sound
'- Rьdiger Hьlsmann	23.12.2010	Included 10 "multi-purpose" dummy switches
'- Rьdiger Hьlsmann	29.12.2010	ASR switch
'- Rьdiger Hьlsmann	04.01.2011	"D-only" gear selector function
'- Rьdiger Hьlsmann	05.01.2011	fog lamp switch, high beam lever animation, clock debugged
'- Rьdiger Hьlsmann	07.01.2011	Wiper lever sound and function debugges, availybility of several cockpit functions depending on bus type (via constfile)
'- Rьdiger Hьlsmann	16.01.2011	Support for wiper turn-switch
'- Rьdiger Hьlsmann	18.01.2011	Old-style gear button sounds
'- Rьdiger Hьlsmann	26.01.2011	Invertable driver door
'- Rьdiger Hьlsmann	26.01.2011	Thermometer
'- Яковлев Вячеслав 04.10.2011  Добавлен электронный тахометр CATerpillar
'- Яковлев Вячеслав 04.10.2011  Добавлены тумблеры и индикаторы двигателя CAT 3126E
'- Яковлев Вячеслав 04.10.2011  Добавлен переключатель аварийного останова двигателя
'- Яковлев Вячеслав 04.10.2011  Добавлен дисплей селектора ГМП Allison
'- Яковлев Вячеслав 04.10.2011  Изменен и дополнен скрипт селектора ГМП Allison
'- Яковлев Вячеслав 19.10.2011  Добавлена блокировка заднего хода, переключатель ретардера, индикаторы блокировки,
'								и ретардера
'- Яковлев Вячеслав	23.10.2011	Добавлены лампы аварийного давления в пневмоконтурах, кнопка проверки индикаторов,
'								индикатор стояночного тормоза
'- Яковлев Вячеслав	01.11.2011	Добавлен электронный одометр и кнопка сброса суточного пробега
'- Яковлев Вячеслав	04.11.2011	Добавлена подсветка приборов
'- Яковлев Вячеслав	17.11.2011	Добавлены переключатели дворников и стеклоомыватель

'------------------------------------------------------------------------------------------

'----------------------
'	Trigger
'----------------------

{trigger:automatic_R}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gang2) (L.L.cockpit_gang3) ||
		{if}
			(L.L.antrieb_getr_gangvorwahl) 1 <= !
				{if}
					(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
				{endif}
			1 (S.L.antrieb_getr_gangvorwahl)
		{endif}
		(L.L.cockpit_gangR_toggle) ! (S.L.cockpit_gangR_toggle)
		(L.L.cockpit_gangR) !
		{if}
			1 (S.L.cockpit_gang_r-frei)
		{endif}
		(L.L.cockpit_gangR_toggle) (L.L.cockpit_gang2_toggle) ! (L.L.cockpit_gang3_toggle) ! && &&
		{if}
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			0 (S.L.antrieb_getr_gangvorwahl)
		{endif}
		(L.L.cockpit_gangR) 1 = !
		{if}
			(L.L.cockpit_gangR_toggle)
			{if}
				(T.L.ev_gangwahltaster_old_on)
			{else}
				(T.L.ev_gangwahltaster_old_off)
			{endif}
		{endif}
		1 (S.L.cockpit_gangR)	
	{else}
		(L.L.antrieb_getr_gangvorwahl) 1 <= 
		{if}
			(L.L.antrieb_getr_gangvorwahl) 0 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			
			0 (S.L.antrieb_getr_gangvorwahl)
				
			1 (S.L.cockpit_gangR)
		{endif}
	{endif}
{end}

{trigger:automatic_R_off}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gangR_toggle) 
		{if}
			0.7 (S.L.cockpit_gangR)
			0 (S.L.cockpit_gang_r-frei)	
		{else}
			(L.L.cockpit_gang3_toggle) (L.L.cockpit_gang2_toggle) ! &&
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				4 (S.L.antrieb_getr_gangvorwahl)
			{else}
				(L.L.cockpit_gang2_toggle) 
				{if}
					(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
					3 (S.L.antrieb_getr_gangvorwahl)
				{else}

					(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
					1 (S.L.antrieb_getr_gangvorwahl)
				{endif}
				
			{endif}
			0 (S.L.cockpit_gangR) 0 (S.L.cockpit_gang_r-frei)	
		{endif}
	{else}
		(L.L.cockpit_gangR) 1 =
		{if}
			0.7 (S.L.cockpit_gangR)
		{endif}
	{endif}
{end}



{trigger:automatic_R_mouse}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gang2) (L.L.cockpit_gang3) ||
		{if}
			(L.L.antrieb_getr_gangvorwahl) 1 <= !
				{if}
					(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
				{endif}
			1 (S.L.antrieb_getr_gangvorwahl)
		{endif}
		(L.L.cockpit_gangR_toggle) ! (S.L.cockpit_gangR_toggle)
		(L.L.cockpit_gangR) 1 = !
		{if}
			(L.L.cockpit_gangR_toggle)
			{if}
				(T.L.ev_gangwahltaster_old_on)
			{else}
				(T.L.ev_gangwahltaster_old_off)
			{endif}
		{endif}
		1 (S.L.cockpit_gangR)	
	{else}
		(L.L.antrieb_getr_gangvorwahl) 1 <= 
		{if}
			(L.L.antrieb_getr_gangvorwahl) 0 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			0 (S.L.antrieb_getr_gangvorwahl)
	
			1 (S.L.cockpit_gangR)
		{endif}
	{endif}
{end}

{trigger:automatic_R_mouse_off}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gangR_toggle) 
		{if}
			0.7 (S.L.cockpit_gangR)
		{else}
			(L.L.cockpit_gang3_toggle) (L.L.cockpit_gang2_toggle) ! &&
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				4 (S.L.antrieb_getr_gangvorwahl)
			{else}
				(L.L.cockpit_gang2_toggle) 
				{if}
					(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
					3 (S.L.antrieb_getr_gangvorwahl)
				{else}

					(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
					1 (S.L.antrieb_getr_gangvorwahl)
				{endif}
				
			{endif}
			0 (S.L.cockpit_gangR)			
		{endif}
	{else}
		(L.L.cockpit_gangR) 1 =
		{if}
			0.7 (S.L.cockpit_gangR)
		{endif}
	{endif}
{end}


{trigger:automatic_N}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gangR_toggle) s1
		{if}
			1 (S.L.cockpit_gangR) 
		{endif}
		(L.L.cockpit_gang2_toggle) s2
		{if}
			1 (S.L.cockpit_gang2)
		{endif}
		(L.L.cockpit_gang3_toggle) s3
		{if}
			1 (S.L.cockpit_gang3)
		{endif}
	
		l1 l2 l3 || ||
		{if}
			(T.L.ev_gangwahltaster_old_off)
		{endif}
	{else}
		(L.L.antrieb_getr_gangvorwahl) 1 = !
			{if}
				(T.L.ev_gangwahltaster_N)
				(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) -  - (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
		1 (S.L.antrieb_getr_gangvorwahl)		
		0 (S.L.cockpit_gangR) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3)
	{endif}	
1 (S.L.cockpit_gangN)
{end}


{trigger:automatic_N_off}
		(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) -  - (S.L.antrieb_getr_gangwahlzeitpunkt)
		0 (S.L.cockpit_gangR) (S.L.cockpit_gang2) (S.L.cockpit_gang3) (S.L.cockpit_gangR_toggle) (S.L.cockpit_gang2_toggle) (S.L.cockpit_gang3_toggle) 
		1 (S.L.antrieb_getr_gangvorwahl)

0 (S.L.cockpit_gangN)
{end}


{trigger:automatic_1}
	(L.L.antrieb_getr_gangvorwahl) 0 > (C.L.cockpit_gangwahltaster_alt) ! &&
	(C.L.cockpit_gear_D_only) ! &&
	{if}
		(L.L.antrieb_getr_gangvorwahl) 2 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		2 (S.L.antrieb_getr_gangvorwahl)
		1 (S.L.cockpit_gang1)
		0 (S.L.cockpit_gang2) (S.L.cockpit_gang3)
	{endif}

{end}


{trigger:automatic_1_off}
	(L.L.cockpit_gang1) 1 =
	{if}
		0.7 (S.L.cockpit_gang1)
	{endif}
{end}

{trigger:automatic_2}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gangR)
		{if}
			(L.L.antrieb_getr_gangvorwahl) 1 = !
				{if}
					(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
				{endif}
			1 (S.L.antrieb_getr_gangvorwahl)
		{else}
			(L.L.antrieb_getr_gangvorwahl) 3 = !
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			3 (S.L.antrieb_getr_gangvorwahl)
		{endif}
		(L.L.cockpit_gang2_toggle) ! (S.L.cockpit_gang2_toggle)
		(L.L.cockpit_gang2) 1 = !
		{if}
			(L.L.cockpit_gang2_toggle)
			{if}
				(T.L.ev_gangwahltaster_old_on)
			{else}
				(T.L.ev_gangwahltaster_old_off)
			{endif}
		{endif}
		1 (S.L.cockpit_gang2)
	{else}
		(L.L.antrieb_getr_gangvorwahl) 0 >
		(C.L.cockpit_gear_D_only) ! &&
		{if}
			(L.L.antrieb_getr_gangvorwahl) 3 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			3 (S.L.antrieb_getr_gangvorwahl)
			1 (S.L.cockpit_gang2)
			0 (S.L.cockpit_gang1) (S.L.cockpit_gang3)
		{endif}
	{endif}
{end}


{trigger:automatic_2_off}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gang2_toggle) 
		{if}
			0.7 (S.L.cockpit_gang2)
		{else}
			(L.L.cockpit_gang3_toggle) (L.L.cockpit_gangR_toggle) ! &&
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				4 (S.L.antrieb_getr_gangvorwahl)
			{else}
				(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
			0 (S.L.cockpit_gang2)			
		{endif}
	{else}
		(L.L.cockpit_gang2) 1 =
		{if}
			0.7 (S.L.cockpit_gang2)
		{endif}
	{endif}
{end}


{trigger:automatic_D}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gangR)
		{if}

			(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
			1 (S.L.antrieb_getr_gangvorwahl)
		{else}
			(L.L.cockpit_gang2_toggle) !
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				7 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
		(L.L.cockpit_gang3_toggle) ! (S.L.cockpit_gang3_toggle)
		(L.L.cockpit_gang3) 1 = !
		{if}
			(L.L.cockpit_gang3_toggle)
			{if}
				(T.L.ev_gangwahltaster_old_on)
			{else}
				(T.L.ev_gangwahltaster_old_off)
			{endif}
		{endif}
		1 (S.L.cockpit_gang3)
	{else}
		(L.L.antrieb_getr_gangvorwahl) 0 >
		{if}
			(L.L.antrieb_getr_gangvorwahl) 7 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			7 (S.L.antrieb_getr_gangvorwahl)
			1 (S.L.cockpit_gang3)
			0 (S.L.cockpit_gang1) (S.L.cockpit_gang2)	
		
		{endif}
	{endif}
{end}


{trigger:automatic_D_off}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gang3_toggle) 
		{if}
			0.7 (S.L.cockpit_gang3)
		{else}
			(L.L.cockpit_gang2_toggle) (L.L.cockpit_gangR_toggle) ! &&
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				3 (S.L.antrieb_getr_gangvorwahl)
			{else}	
				(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
			0 (S.L.cockpit_gang3)
		{endif}
	{else}
		(L.L.cockpit_gang3) 1 =
		{if}
			0.7 (S.L.cockpit_gang3)
		{endif}	
	{endif}
{end}


{trigger:automatic_r-frei}
	1 (S.L.cockpit_gang_r-frei)
	(L.L.cockpit_gangR_toggle) (L.L.cockpit_gang2_toggle) ! (L.L.cockpit_gang3_toggle) ! && &&
	{if}
		(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		0 (S.L.antrieb_getr_gangvorwahl)
	{endif}
{end}

{trigger:automatic_r-frei_off}
	0 (S.L.cockpit_gang_r-frei)
{end}

'-------------------------------------------
' Звуковой сигнал с клавиатуры
'-------------------------------------------

{trigger:horn}
	
	(L.L.cockpit_hupe) ! &&
	{if}
		(T.L.ev_hupe_an)
	{endif}
	1 (S.L.cockpit_hupe)
	
{end}

{trigger:horn_off}	
	
	(L.L.cockpit_hupe) &&
	{if}
		(T.L.ev_hupe_aus)
	{endif}
	0 (S.L.cockpit_hupe)	
	
{end}

'-------------------------------------------
' Управление гидрозамедлителем (ретардером)
' Включение ретардера не нажимая на педаль тормоза
'-------------------------------------------

{trigger:cp_retarder_direkt_toggle}
	(L.L.cp_retarder_sw_direkt) ! (S.L.cp_retarder_sw_direkt) s1
	(M.L.kippschaltersound)
{end}

'--------------------------------------------
' Включает ретардер при нажатии на педаль тормоза (в ЛиАЗ 5256 этот тумблер не используется)
'--------------------------------------------
{trigger:cp_retarder_toggle}
	(C.L.cockpit_has_retarderswitch)
	{if}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}
'--------------------------------------------

{trigger:cp_motorkuehlung_toggle}
	(C.L.cockpit_has_coolingswitch)
	{if}
		(L.L.cp_motorkuehlung_sw) ! (S.L.cp_motorkuehlung_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

'-------------------------------------------
' Переключатель освещения кабины водителя
'-------------------------------------------
{trigger:cp_fahrerlicht_toggle}
	(L.L.cp_fahrerlicht_sw) ! (S.L.cp_fahrerlicht_sw) s1
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
' Переключатель освещения около 1-ой двери 
' В ЛиАЗ 5256 не используется
'-------------------------------------------
'{trigger:cp_licht_untenrechts_toggle}
'	(L.L.cp_licht_untenrechts_sw) 
'	{if}
'		0 (S.L.cp_licht_untenrechts_sw) s1
'	{else}
'		1 (S.L.cp_licht_untenrechts_sw) s1
'	{endif}		
'	(M.L.kippschaltersound)
'{end}

'-------------------------------------------
' Переключатель освещения верхнего этажа
' В ЛиАЗ 5256- включение первой лампочки в каждом плафоне освещения салона
'-------------------------------------------
{trigger:cp_licht_oberdeck_toggle}
	(L.L.cp_licht_oberdeck_sw) 
	{if}
		0 (S.L.cp_licht_oberdeck_sw) s1
	{else}
		1 (S.L.cp_licht_oberdeck_sw) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
' Переключатель освещения нижнего этажа
' В ЛиАЗ 5256- включение второй лампочки в каждом плафоне освещения салона
'-------------------------------------------
{trigger:cp_licht_unterdeck_toggle}
	(L.L.cp_licht_unterdeck_sw) 
	{if}
		0 (S.L.cp_licht_unterdeck_sw) s1
	{else}
		1 (S.L.cp_licht_unterdeck_sw) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

'{trigger:cp_wischer_schnell_toggle}
'	(L.L.cp_wischer_schnell_sw) ! (S.L.cp_wischer_schnell_sw) s1
'	(M.L.kippschaltersound)
'{end}

'{trigger:kw_wipermode_up}
'	(L.L.cp_wischer_einaus_sw) ! (S.L.cp_wischer_einaus_sw) s1
'	{if}
'		2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
'		2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
'		(L.L.cp_wischer_intervall_sw) !
'		{if}
'			(T.L.ev_wischerhebel)
'		{endif}
'	{else}
'		(L.L.cp_wischer_intervall_sw)
'		{if}
'			1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
'			1 3 / (S.L.cockpit_wischerhebel) 
'			0 (S.L.cockpit_wischer_drehschalter)
'		{else}
'			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel) 
'			1 3 / (S.L.cockpit_wischer_drehschalter)
'			(T.L.ev_wischerhebel)
'		{endif}
'	{endif}
'	(C.L.wiper_lever) !
'	{if}
'		l1 (M.L.kippschaltersound)
'	{endif}
'{end}

'{trigger:cp_wischer_intervall_toggle}
'	(L.L.cp_wischer_intervall_sw) ! (S.L.cp_wischer_intervall_sw) s1
'	(L.L.cp_wischer_einaus_sw) ! &&
'	{if}
'		1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
'		1 3 / (S.L.cockpit_wischerhebel) 
'		0 (S.L.cockpit_wischer_drehschalter)
'	{else}
'		(L.L.cp_wischer_einaus_sw)
'		{if}
'			2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
'			2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
'		{else}
'			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel)
'			1 3 / (S.L.cockpit_wischer_drehschalter)
'		{endif}
'
'	{endif}
'	(C.L.wiper_lever) !
'	{if}
'		l1 (M.L.kippschaltersound)
'	{endif}
'{end}
'------------------------------------------------------------------------------------------------------------

'-------------------------------------------
'	Кнопка включения омывателя лобового стекла
'-------------------------------------------
{trigger:cp_wischer_wascher_button}
	1 (S.L.cp_wischer_wascher_sw) s1
	(C.L.wiper_lever)
	{if}
		(T.L.ev_wischerhebel)
		1 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_wascher_button_off}
	0 (S.L.cp_wischer_wascher_sw) s1
	(S.L.wiper_wascher_sw)
	(C.L.wiper_lever)
	{if}
		(T.L.ev_wischerhebel)
		0 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_heizluefter_toggle}
	(L.L.cp_heizluefter_sw) ! (S.L.cp_heizluefter_sw) s1
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
' Переключатель обогрева зеркал
'-------------------------------------------
{trigger:cp_spiegelheizung_toggle}
	(L.L.cp_spiegelheizung_sw) ! (S.L.cp_spiegelheizung_sw) s1
	(M.L.kippschaltersound)
{end}



{trigger:cp_dummy_sw01_toggle}
	(L.L.cp_dummy_sw01) ! (S.L.cp_dummy_sw01) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw02_toggle}
	(L.L.cp_dummy_sw02) ! (S.L.cp_dummy_sw02) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw03_toggle}
	(L.L.cp_dummy_sw03) ! (S.L.cp_dummy_sw03) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw04_toggle}
	(L.L.cp_dummy_sw04) ! (S.L.cp_dummy_sw04) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw05_toggle}
	(L.L.cp_dummy_sw05) ! (S.L.cp_dummy_sw05) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw06_toggle}
	(L.L.cp_dummy_sw06) ! (S.L.cp_dummy_sw06) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw07_toggle}
	(L.L.cp_dummy_sw07) ! (S.L.cp_dummy_sw07) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw08_toggle}
	(L.L.cp_dummy_sw08) ! (S.L.cp_dummy_sw08) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw09_toggle}
	(L.L.cp_dummy_sw09) ! (S.L.cp_dummy_sw09) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw10_toggle}
	(L.L.cp_dummy_sw10) ! (S.L.cp_dummy_sw10) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw11_toggle}
	(L.L.cp_dummy_sw11) ! (S.L.cp_dummy_sw11) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw22_toggle}
	(L.L.cp_dummy_sw22) ! (S.L.cp_dummy_sw22) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw33_toggle}
	(L.L.cp_dummy_sw33) ! (S.L.cp_dummy_sw33) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw44_toggle}
	(L.L.cp_dummy_sw44) ! (S.L.cp_dummy_sw44) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw55_toggle}
	(L.L.cp_dummy_sw55) ! (S.L.cp_dummy_sw55) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw66_toggle}
	(L.L.cp_dummy_sw66) ! (S.L.cp_dummy_sw66) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw77_toggle}
	(L.L.cp_dummy_sw77) ! (S.L.cp_dummy_sw77) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw88_toggle}
	(L.L.cp_dummy_sw88) ! (S.L.cp_dummy_sw88) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw99_toggle}
	(L.L.cp_dummy_sw99) ! (S.L.cp_dummy_sw99) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_ASR_off_toggle}
	(L.L.cp_ASR_off) ! (S.L.cp_ASR_off) s1
	(M.L.kippschaltersound)
{end}





{trigger:cp_klimator_sw_drag}
	(L.S.mouse_y) -100 / (L.L.cp_klimator_sw) + (S.L.cp_klimator_sw) s0
	l0 0 <
	{if}
		0 (S.L.cp_klimator_sw)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_klimator_sw)
	{endif}
{end}

'-------------------------------------------
' Солнцезащитная шторка
'-------------------------------------------

{trigger:cp_rollo_drag}

	(L.L.cp_rollo_pos) (S.L.cp_rollo_lastpos)

	1 (S.L.cp_rollo_dragged)
	0 (S.L.cp_rollo_speed)
	(L.S.mouse_y) 500 / (L.L.cp_rollo_pos) + (S.L.cp_rollo_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_rollo_pos)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_rollo_pos)
	{endif}

	(L.L.cp_rollo_pos) (L.L.cp_rollo_lastpos) - abs (L.S.Timegap) / (S.L.cp_rollo_speed)

{end}

{trigger:cp_rollo_off}
	0 (S.L.cp_rollo_dragged)
	(T.L.ev_rollo_end)
{end}

{trigger:cp_rollo_retract}
	(L.L.cp_rollo_bommel) 0 = (L.L.cp_rollo_pos) &&
	{if}
		(T.L.ev_rollo_retract)
	{endif}
	1 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract)

{end}

{trigger:cp_rollo_retract_off}
	0 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract) (S.L.cp_rollo_speed)
{end}

'-------------------------------------------
' Рулевая колонка
'-------------------------------------------

{trigger:cp_lenkrad_toggle}
	(L.L.cp_lenkrad_visible) ! (S.L.cp_lenkrad_visible)
{end}

{trigger:KR_play}
	(L.L.cockpit_KR_play) 0.1 < 
	{if}
		(T.L.ev_kr_play)
	{endif}
	1 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
{end}


{trigger:KR_play_off}
	0.8 (S.L.cockpit_KR_play)
{end}

{trigger:KR_stop}
	1 (S.L.cockpit_KR_stop)
	0 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	(T.L.ev_kr_stop)
{end}


{trigger:KR_stop_off}
	0 (S.L.cockpit_KR_stop)
{end}


'-------------------------------------------
' Печка
'-------------------------------------------
'{trigger:taster_standheizung}
'
'	(L.L.cp_taster_standheizung_target) ! (S.L.cp_taster_standheizung_target) s1
'
'	1 (S.L.cp_taster_standheizung)
'
'	(C.L.auxheat_via_button) !
'	{if}
'		l1 (M.L.kippschaltersound)
'		l0 (S.L.cp_taster_standheizung)
'	{endif}
'		
'{end}

'{trigger:taster_standheizung_off}
'	
'	(L.L.cp_taster_standheizung_target)
'	{if}
'		0 (S.L.cp_taster_standheizung)
'	{else}
'		0.6 (S.L.cp_taster_standheizung)
'	{endif}
'
'{end}


'{trigger:taster_nebelschluss}

'	(L.L.cp_taster_nebelschluss_target) ! (S.L.cp_taster_nebelschluss_target)
'	1 (S.L.cp_taster_nebelschluss)		
'{end}

'{trigger:taster_nebelschluss_off}
	
'	(L.L.cp_taster_nebelschluss_target)
'	{if}
'		0.6 (S.L.cp_taster_nebelschluss)
'	{else}
'		0 (S.L.cp_taster_nebelschluss)
'	{endif}
'
'{end}

'----------------------------------------------------------------------------------------------------------------
'{trigger:cp_wiperlever_drag}

'	Fallunterscheidung: Hebel in x- oder y-Richtung?

'	(C.L.wiper_lever)
'	{if}
'	
'		(L.S.mouse_y) abs (L.S.mouse_x) abs >=
'		{if}
'			(L.S.mouse_y) -50 / (L.L.cockpit_wischerhebel) + 0 max 1 min (S.L.cockpit_wischerhebel) s0
		
'			Stufen:
'			0: Aus
'			1: Intervall
'			2: Langsam
'			3: Schnell

'			l0 0.17 <
'			{if}
'				0 (S.L.cockpit_wischerhebel_mode) (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
'			{else} 
'				l0 0.5 <
'				{if}
'					1 (S.L.cockpit_wischerhebel_mode) (S.L.cp_wischer_intervall_sw)
'					0 (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)
'				{else}
'					l0 0.83 <
'					{if}
'						2 (S.L.cockpit_wischerhebel_mode)
'						1 (S.L.cp_wischer_einaus_sw)
'						0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
'					{else}
'						3 (S.L.cockpit_wischerhebel_mode)
'						1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
'						0 (S.L.cp_wischer_intervall_sw)
'					{endif}
'				{endif}
'			{endif}
'		{else}
'			(L.S.mouse_x) -50 / (L.L.cockpit_wischerhebel_x) + 0 max 1 min (S.L.cockpit_wischerhebel_x) s1

'			Waschanlage (Hebel nach oben)	
'			l1 0.9 >
'			{if}
'				(L.L.cp_wischer_wascher_sw) !
'				{if}
'					(T.L.ev_wischerhebel)
'				{endif}
'				1 (S.L.cp_wischer_wascher_sw)
'			{else}
'				(L.L.cp_wischer_wascher_sw)
'				{if}
'					(T.L.ev_wischerhebel)
'				{endif}
'				0 (S.L.cp_wischer_wascher_sw)
'			{endif}
'
'		{endif}
'	{endif}

'{end}

'{trigger:cp_wiperlever_off}

'	Einrasten auf den festen Positionen:
'	(L.L.cockpit_wischerhebel_mode) 3 / (S.L.cockpit_wischerhebel)
'	(L.L.cp_wischer_wascher_sw)
'	{if}
'		(T.L.ev_wischerhebel)
'		0 (S.L.cockpit_wischerhebel_x) (S.L.cp_wischer_wascher_sw)
'	{endif}
'{end}


'{trigger:cp_wiper_turnswitch_drag}

'	(C.L.wiper_turnswitch)
'	{if}
	
'		(L.S.mouse_y) -50 / (L.L.cockpit_wischer_drehschalter) + 0 max 1 min (S.L.cockpit_wischer_drehschalter) s0
	
'		Stufen:
'		0: Intervall
'		1: Aus
'		2: Langsam
'		3: Schnell
'
'		l0 0.17 <
'		{if}
'			1 (S.L.cp_wischer_intervall_sw)
'			0 (S.L.cockpit_wischer_drehschalter_mode) (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)		
'		{else} 
'			l0 0.5 <
'			{if}
'				0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
'				1 (S.L.cockpit_wischer_drehschalter_mode)
'			{else}
'				l0 0.83 <
'				{if}
'					2 (S.L.cockpit_wischer_drehschalter_mode)
'					1 (S.L.cp_wischer_einaus_sw)
'					0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
'				{else}
'					3 (S.L.cockpit_wischer_drehschalter_mode)
'					1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
'					0 (S.L.cp_wischer_intervall_sw)
'				{endif}
'			{endif}
'		{endif}
'	{endif}

'{end}

'{trigger:cp_wiper_turnswitch_off}

'	Einrasten auf den festen Positionen:
'	(L.L.cockpit_wischer_drehschalter_mode) 3 / (S.L.cockpit_wischer_drehschalter)
'{end}

'-----------------------------------------------------------------------------------------------------------------------
	
{trigger:cp_microphone}
	1 (S.L.cp_microphone_sw)
{end}

{trigger:cp_microphone_off}
	0 (S.L.cp_microphone_sw)
{end}



{trigger:cp_heizregler_defrost_drag}
	(L.S.mouse_x) -70 / (L.L.cockpit_heizregler_defrost) + 0 max 1 min (S.L.cockpit_heizregler_defrost)
{end}

{trigger:cp_heizregler_fussraum_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_fussraum) + 0 max 1 min (S.L.cockpit_heizregler_fussraum)
{end}

{trigger:cp_heizregler_temp_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_temp) + 0 max 1 min (S.L.cockpit_heizregler_temp)
{end}

{trigger:cp_heizregler_bug_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_bug) + 0 max 1 min (S.L.cockpit_heizregler_bug)
{end}

{trigger:cp_heizregler_umluft_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_umluft) + 0 max 1 min (S.L.cockpit_heizregler_umluft) s0

'	Stufen:
'	0: Umluftheizung Конвекция нагретого воздуха
'	1: Direktbelьftung Поступление свежего воздуха
'	2: Frischluftheizung Нагрев свежего воздуха

	l0 0.2 <
	{if}
		0 (S.L.cockpit_heizregler_ventilation_mode)
	{else}
		l0 0.8 <
		{if}
			1 (S.L.cockpit_heizregler_ventilation_mode)
		{else}
			2 (S.L.cockpit_heizregler_ventilation_mode)
		{endif}
	{endif}

{end}

{trigger:cp_heizregler_umluft_off}
	(L.L.cockpit_heizregler_ventilation_mode) 2 / (S.L.cockpit_heizregler_umluft)

{end}

'-------------------------------------------
'Переключатель аварийного останова двигателя и выключения "массы" и его крышка
'-------------------------------------------

{trigger:cp_avariinoe_vykl_kryshka}
	(L.L.cp_avariinoe_vykl_kryshka) ! (S.L.cp_avariinoe_vykl_kryshka) s1
	(T.L.ev_avar_kr)
{end}

{trigger:cp_avar_mov_drag}
	
'	(L.S.mouse_y) abs (L.S.mouse_x) abs >=
'	{if}
	
		(L.S.mouse_x) -20 / (L.L.cp_avar_rot) + 0 max 1 min (S.L.cp_avar_rot) s1

'		Положения:
'		0: Исходная позиция
'		1: Останов двигателя
'		2: Выключение "массы" (нефиксированное)

		l1 0.2 <
		{if}
			0 (S.L.cp_avar_rot_mode)			
		{else} 
			l1 0.5 <
			l1 0.2 > &&
			{if}
'				Блок скрипта останова двигателя через выключатель (перевод в 1-е положение)	
				
				(L.L.elec_busbar_main)
				(L.L.engine_injection_on) &&
				(L.L.cp_avar_rot_mode) ! &&
				{if}
					0 (S.L.engine_injection_on)
				{endif}	
				
				1 (S.L.cp_avar_rot_mode)			
			{else}
				l1 1 =
				{if}
'					Блок выключения массы (2-е нефиксированное положение)
					(L.L.elec_busbar_main_sw) 0 >
					{if}
						0 (S.L.elec_busbar_main_sw)
					{endif}
					
					1 (S.L.cp_avar_rot_mode)
				{endif}
			{endif}
		{endif}
'	{endif}
{end}

{trigger:cp_avar_mov_off}

'	Привязка ключа к фиксированным положениям
	(L.L.cp_avar_rot_mode) 2 / (S.L.cp_avar_rot)

{end}

'-------------------------------------------
'Тумблеры регулятора оборотов и диагностики двигателя
'-------------------------------------------

{trigger:cp_tmb_CAT_RPM}

'	Переключение тумблера в 1-е положение (900 оборотов)	
	(L.L.tmb_CAT_rpm_polozhenie) 0 =
	{if}
		1 (S.L.tmb_CAT_rpm_p1)
		1 (S.L.tmb_CAT_rpm_polozhenie)
		
'		Проверка на продолжение действия- нужно чтобы скрипт не продолжил выполнятся, иначе тумблер переключится
'		на 0-е или 2-е положение (1000 оборотов)
		(L.L.tmb_CAT_rpm_antirepeat1) 1 =
		{if}
			0 (S.L.tmb_CAT_rpm_antirepeat1)
		{else}
			1 (S.L.tmb_CAT_rpm_antirepeat1)
		{endif}
	{endif}
	
'	Переключение тумблера в 2-е положение (1000 оборотов)	
	(L.L.tmb_CAT_rpm_antirepeat1) 0 =
	(L.L.tmb_CAT_rpm_polozhenie) 1 = &&
	{if}
		1 (S.L.tmb_CAT_rpm_p1)
		2 (S.L.tmb_CAT_rpm_polozhenie)
	{endif}

'	Проверка на продолжение действия- чтобы скрипт не продолжил выполнятся, иначе тумблер перейдет в 0-е положение
	(L.L.tmb_CAT_rpm_antirepeat2) 1 =
	{if}
		0 (S.L.tmb_CAT_rpm_antirepeat2)
	{else}
		1 (S.L.tmb_CAT_rpm_antirepeat2)
	{endif}

'	Переключение тумблера в 0-е положение (обычные холостые обороты)	
	(L.L.tmb_CAT_rpm_antirepeat2) 0 =
	{if}
		0 (S.L.tmb_CAT_rpm_p1)
		0 (S.L.tmb_CAT_rpm_polozhenie)
	{endif}
					
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Кнопка разблокировки заднего хода
'-------------------------------------------
{trigger:knp_rear_blocking}
	(L.L.antrieb_rear_blocking) 1 =
	{if}
		0 (S.L.antrieb_rear_blocking)
	{endif}
	1 (S.L.cockpit_rear_blocking)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_rear_blocking_off}
	0 (S.L.cockpit_rear_blocking)
{end}

'-------------------------------------------
'	Кнопка проверки работоспособности правого ряда индикаторов
'-------------------------------------------
{trigger:knp_proverka2}
	1 (S.L.cockpit_proverka2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_proverka2_off}
	0 (S.L.cockpit_proverka2)
{end}

'-------------------------------------------
'	Пустая кнопка (просто анимация)
'-------------------------------------------
{trigger:knp_dummy}
	1 (S.L.cockpit_dummy)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_off}
	0 (S.L.cockpit_dummy)
{end}

{trigger:knp_dummy_2}
	1 (S.L.cockpit_dummy_2)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_2_off}
	0 (S.L.cockpit_dummy_2)
{end}

{trigger:knp_dummy_11}
	1 (S.L.cockpit_dummy_11)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_11_off}
	0 (S.L.cockpit_dummy_11)
{end}

{trigger:knp_dummy_22}
	1 (S.L.cockpit_dummy_22)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_22_off}
	0 (S.L.cockpit_dummy_22)
{end}

{trigger:knp_dummy_33}
	1 (S.L.cockpit_dummy_33)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_33_off}
	0 (S.L.cockpit_dummy_33)
{end}

{trigger:knp_dummy_44}
	1 (S.L.cockpit_dummy_44)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_44_off}
	0 (S.L.cockpit_dummy_44)
{end}

{trigger:knp_dummy_55}
	1 (S.L.cockpit_dummy_55)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_55_off}
	0 (S.L.cockpit_dummy_55)
{end}

{trigger:knp_dummy_66}
	1 (S.L.cockpit_dummy_66)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_66_off}
	0 (S.L.cockpit_dummy_66)
{end}

{trigger:knp_dummy_77}
	1 (S.L.cockpit_dummy_77)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_77_off}
	0 (S.L.cockpit_dummy_77)
{end}

{trigger:knp_dummy_88}
	1 (S.L.cockpit_dummy_88)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_88_off}
	0 (S.L.cockpit_dummy_88)
{end}

{trigger:knp_dummy_99}
	1 (S.L.cockpit_dummy_99)
'	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_dummy_99_off}
	0 (S.L.cockpit_dummy_99)
{end}

'-------------------------------------------
'	Водительская дверь
'-------------------------------------------

{trigger:cp_fahrerfenster_opn_drag}

	(L.L.cp_fahrerfenster_pos) (S.L.cp_fahrerfenster_lastpos)

	(L.S.mouse_x) -500 / (L.L.cp_fahrerfenster_pos) + (S.L.cp_fahrerfenster_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.cp_fahrerfenster_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.cp_fahrerfenster_pos) (L.L.cp_fahrerfenster_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


{trigger:cp_fahrerfenster_opn_off}
	0 (S.L.cp_fahrerfenster_speed)
{end}

{trigger:cp_Fahrertuer_drag}

	1 (S.L.cp_fahrertuer_dragged)
	(L.L.cp_fahrertuer_pos) (S.L.cp_fahrertuer_lastpos)

	(L.S.mouse_x) 500 / (L.L.cp_fahrertuer_pos) + (S.L.cp_fahrertuer_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrertuer_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrertuer_pos)
	{endif}

	(L.L.cp_fahrertuer_pos) (L.L.cp_fahrertuer_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_speed)
{end}


{trigger:cp_Fahrertuer_off}
	0 (S.L.cp_fahrertuer_dragged)
{end}

'-------------------------------------------
'	Кнопка сброса суточного пробега
'-------------------------------------------
{trigger:knp_odometr_sbros}
	(L.L.elec_priborka_voltage) 1 =
	{if}
		(L.L.kmcounter_km) (S.L.odometer_kmlast)
		(L.L.kmcounter_m) (S.L.odometer_mlast)
		0 (S.L.odometr_sutki)
		0 (S.L.odometr_sutki_metr)
	{endif}

	1 (S.L.cockpit_odometr_sbros)
{end}

{trigger:knp_odometr_sbros_off}
	0 (S.L.cockpit_odometr_sbros)
{end}

'-------------------------------------------
'	Переключатель подсветки приборов
'-------------------------------------------
{trigger:cp_podsvetka}
	(L.L.cp_podsvetka_trans) !
	{if}
		1 (S.L.cp_podsvetka_trans)
		(L.L.elec_busbar_main)
		{if}
			1 (S.L.light_podsvetka)
		{endif}
	{else} 
		0 (S.L.cp_podsvetka_trans)
	{endif}
	
	(M.L.podsvetka_frame)
{end}

'-------------------------------------------
'Комбинированный переключатель света
'-------------------------------------------

{trigger:cp_gitara_selector_drag}
		
		
		
		(L.S.mouse_y) -20 / (L.L.cp_gitara_rot1) + 0 max 1 min (S.L.cp_gitara_rot1) s1
		(L.S.mouse_y) 80 / (L.L.cp_gitara_rot2) + 0 max 1 min (S.L.cp_gitara_rot2) s2

'		Положения переключателя:
'		-1: Включены габариты, дальний свет (нефиксированное)
'		0: Выключено все освещение
'		1: Включены габариты
'		2: Включены габариты и ближний свет
'		3: Включены габариты, дальний свет

'		Если курсор мыши отведен полностью вверх, то врубается положение -1
		l1 1 =
		{if}
			1 (S.L.cp_gitara_rot_mode1)
			0 (S.L.cp_gitara_rot_mode2)
		{else}

'			Если курсор мыши отведен вниз на 20%, то врубается положение 0		
			l2 0.2 <
			{if}
				0 (S.L.cp_gitara_rot_mode1) (S.L.cp_gitara_rot_mode2)
			{else}
'				Если курсор мыши отведен вниз на 50%, то врубается положение 1	
				l2 0.5 <
				{if}
					0 (S.L.cp_gitara_rot_mode1)
					3 (S.L.cp_gitara_rot_mode2)
				{else}
'					Если курсор мыши отведен вниз на 80%, то врубается положение 2				
					l2 0.8 <
					{if}
						0 (S.L.cp_gitara_rot_mode1)
						6 (S.L.cp_gitara_rot_mode2)
					{else}
'						Если курсор мыши отведен полностью вниз, то врубается положение 3
						l2 1 =
						{if}
							0 (S.L.cp_gitara_rot_mode1)
							8 (S.L.cp_gitara_rot_mode2)
						{endif}
					{endif}
				{endif}
			{endif}
		{endif}
		
'	(L.L.cp_gitara_rot_last) (L.L.cp_gitara_rot_mode2) =
'	{if}
'		
'	{else}
'		(T.L.ev_gitara)
'		(L.L.cp_gitara_rot_mode2) (S.L.cp_gitara_rot_last)
'	{endif}
'	(M.L.sound_frame)	
{end}


{trigger:cp_gitara_selector_off}
'	Привязка к фиксированным положениям
	0 (S.L.cp_gitara_rot_mode1) (S.L.cp_gitara_rot1)
	(L.L.cp_gitara_rot_mode2) 8 / (S.L.cp_gitara_rot2)
	
'	(T.L.ev_gitara)
{end}

'-------------------------------------------
'	Переключатель стояночных огней
'-------------------------------------------
{trigger:knp_stoyanochnye_ogni}
	(L.L.cp_stoyanochnye_ogni) !
	{if}
		1 (S.L.cp_stoyanochnye_ogni) s1
	{else}
		0 (S.L.cp_stoyanochnye_ogni) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель передних противотуманных фонарей
'-------------------------------------------
{trigger:knp_PT}
	(L.L.cp_PT) !
	{if}
		1 (S.L.cp_PT) s1
	{else}
		0 (S.L.cp_PT) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель заднего противотуманного фонаря
'-------------------------------------------
{trigger:knp_PT_rear}
	(L.L.cp_PT_rear) !
	{if}
		1 (S.L.cp_PT_rear) s1
	{else}
		0 (S.L.cp_PT_rear) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'Переключатель указателей поворота и звукового сигнала
'-------------------------------------------

{trigger:cp_blinkers_selector_drag}
		
	(L.S.mouse_y) -40 / (L.L.cp_blinkers_rot1) + 0 max 1 min (S.L.cp_blinkers_rot1) s1
	(L.S.mouse_y) 40 / (L.L.cp_blinkers_rot2) + 0 max 1 min (S.L.cp_blinkers_rot2) s2

'	Если мышь оттянута полностью вверх, то включается правый поворотник, положение фиксируется
	l1 1 =
	{if}
		1 (S.L.cp_blinkers_rot_mode1)
		0 (S.L.cp_blinkers_rot_mode2)
	{else}
		l2 1 =
		{if}
'			если мышь оттянута полностью вниз, то включается нижний поворотник, положение фиксируется,
			0 (S.L.cp_blinkers_rot_mode1)
			1 (S.L.cp_blinkers_rot_mode2)
		{else}
'			если мышь не была оттянута полностью, то поворотники выключаются, переключатель переходит в нейтральное положение
			0 (S.L.cp_blinkers_rot_mode1) (S.L.cp_blinkers_rot_mode2)
		{endif}
	{end}


{trigger:cp_blinkers_selector_off}

'	Привязка к фиксированным положениям
	(L.L.cp_blinkers_rot_mode1) (S.L.cp_blinkers_rot1)
	(L.L.cp_blinkers_rot_mode2) (S.L.cp_blinkers_rot2)
{end}

'-------------------------------------------
'Переключатель подсветки маршрутоуказателей
'-------------------------------------------
{trigger:knp_marshrutniki_podsvetka}
	(L.L.cp_marshrutniki_podsvetka) !
	{if}
		1 (S.L.cp_marshrutniki_podsvetka) s1
	{else}
		0 (S.L.cp_marshrutniki_podsvetka) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Кнопка проверки работоспособности левого ряда индикаторов
'-------------------------------------------
{trigger:knp_proverka1}
	1 (S.L.cockpit_proverka1)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:knp_proverka1_off}
	0 (S.L.cockpit_proverka1)
{end}

'-------------------------------------------
'Переключатель включения левого стеклоочистителя
'-------------------------------------------
{trigger:knp_dvornik_left}
	(L.L.cp_dvornik_left) !
	{if}
		1 (S.L.cp_dvornik_left) s1
		(S.L.wiper_einaus_sw_L)
	{else}
		0 (S.L.cp_dvornik_left) s1
		(S.L.wiper_einaus_sw_L)
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'Переключатель включения правого стеклоочистителя
'-------------------------------------------
{trigger:knp_dvornik_right}
	(L.L.cp_dvornik_right) !
	{if}
		1 (S.L.cp_dvornik_right) s1
		(S.L.wiper_einaus_sw_R)
	{else}
		0 (S.L.cp_dvornik_right) s1
		(S.L.wiper_einaus_sw_R)
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель одновременного включения жидкостного подогревателя и циркуляционного насоса
'-------------------------------------------
{trigger:knp_EFU}
	(L.L.cp_EFU) !
	{if}
		1 (S.L.cp_EFU) (S.L.EFU_target) s1
	{else}
		0 (S.L.cp_EFU) (S.L.EFU_target) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель автономного включения циркуляционного насоса
'-------------------------------------------
{trigger:knp_CN}
	(L.L.cp_CN) !
	{if}
		1 (S.L.cp_CN) (S.L.CN_running) s1
	{else}
		0 (S.L.cp_CN) (S.L.CN_running) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель включения потолочных вентиляторов
'-------------------------------------------
{trigger:knp_potolok_vent}
	(L.L.cp_potolok_vent) !
	{if}
		1 (S.L.cp_potolok_vent) s1
	{else}
		0 (S.L.cp_potolok_vent) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}


'-------------------------------------------
'	Переключатель двурежимного переднего отопителя
'-------------------------------------------
{trigger:knp_pered_otopitel}
	(L.L.cp_pered_otopitel) !
	{if}
		1 (S.L.cp_pered_otopitel) s1
	{else}
		0 (S.L.cp_pered_otopitel) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}


'-------------------------------------------
'	Переключатель поворотного вентилятора кабины
'-------------------------------------------
{trigger:knp_povorot_vent}
	(L.L.cp_povorot_vent) !
	{if}
		1 (S.L.cp_povorot_vent) s1
	{else}
		0 (S.L.cp_povorot_vent) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}


'-------------------------------------------
'	Переключатель отопителя кабины
'-------------------------------------------
{trigger:knp_kabina_otopitel}
	(L.L.cp_kabina_otopitel) !
	{if}
		1 (S.L.cp_kabina_otopitel) s1
	{else}
		0 (S.L.cp_kabina_otopitel) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель 1-ой пары салонных отопителей
'-------------------------------------------
{trigger:knp_salon_otopitel_1}
	(L.L.cp_salon_otopitel_1) !
	{if}
		1 (S.L.cp_salon_otopitel_1) s1
	{else}
		0 (S.L.cp_salon_otopitel_1) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
'	Переключатель 2-ой пары салонных отопителей
'-------------------------------------------
{trigger:knp_salon_otopitel_2}
	(L.L.cp_salon_otopitel_2) !
	{if}
		1 (S.L.cp_salon_otopitel_2) s1
	{else}
		0 (S.L.cp_salon_otopitel_2) s1
	{endif}
	
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
' Таблички
'-------------------------------------------

{trigger:cp_tabl_toggle}
	(L.L.cp_tabl1_visible) ! (S.L.cp_tabl1_visible)
	(L.L.cp_tabl2_visible) ! (S.L.cp_tabl2_visible)
{end}

'-------------------------------------------
' Кнопка включения подсветки на термометре
'-------------------------------------------
{trigger:cp_termo_light}
	(L.L.cp_termo_podsvetka) ! (S.L.cp_termo_podsvetka)
{end}

'-------------------------------------------
' Кнопки на таймере
'-------------------------------------------
{trigger:cp_timer_back}
	(L.L.cp_timer_mode) 1 = 
	{if}
		0 (S.L.cp_timer_mode)
	{endif}
{end}

{trigger:cp_timer_stop}
	(L.L.cp_timer_stop_position) !
	(L.L.cp_timer_mode) 0 = &&
	{if}
		1 (S.L.cp_timer_stop_position)
	{else}
		(L.S.Time) (S.L.cp_timer_minus)
		0 (S.L.cp_timer_stop_position)
	{endif}
{end}

{trigger:cp_timer_stop_off}
	0 (S.L.cp_timer_delay)
{end}

{trigger:cp_timer_next}
	(L.L.cp_timer_mode) ! 
	{if}
		1 (S.L.cp_timer_mode)
	{endif}
{end}

'-------------------------------------------
' Люки
'-------------------------------------------

{trigger:cp_klappfenster_OR1}
	(L.L.cp_klappfenster_OR1) ! (S.L.cp_klappfenster_OR1) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR2}
	(L.L.cp_klappfenster_OR2) ! (S.L.cp_klappfenster_OR2) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR3}
	(L.L.cp_klappfenster_OR3) ! (S.L.cp_klappfenster_OR3) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR4}
	(L.L.cp_klappfenster_OR4) ! (S.L.cp_klappfenster_OR4) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR5}
	(L.L.cp_klappfenster_OR5) ! (S.L.cp_klappfenster_OR5) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR6}
	(L.L.cp_klappfenster_OR6) ! (S.L.cp_klappfenster_OR6) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR7}
	(L.L.cp_klappfenster_OR7) ! (S.L.cp_klappfenster_OR7) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR8}
	(L.L.cp_klappfenster_OR8) ! (S.L.cp_klappfenster_OR8) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UL1}
	(L.L.cp_klappfenster_UL1) ! (S.L.cp_klappfenster_UL1) s1
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
' Кнопка включения бортовой сети 12В
'-------------------------------------------
{trigger:knp_dop_obor}
	(L.L.cp_dop_obor) ! (S.L.cp_dop_obor) s1
	(M.L.kippschaltersound)
{end}

'-------------------------------------------
' Кнопка включения магнитолы
'-------------------------------------------
{trigger:cp_magnitola_btn}
	(L.L.cp_magnitola_on) ! (S.L.cp_magnitola_on)
{end}

'----------------------
'	Init
'----------------------

{macro:cockpit_init}
	0 (S.L.cockpit_hupe_volume) (S.L.door_handsteuerung) (S.L.cp_timer_delay)
	1 (S.L.cp_retarder_sw) (S.L.cp_lenkrad_visible) (S.L.cp_taster_warnblinker) (S.L.cockpit_wischer_drehschalter_mode) 

	0.6 (S.L.cp_taster_warnblinker) (S.L.cp_taster_standheizung)

	(C.L.cockpit_zentralschmierung_dist) random (S.L.cp_zentralschmierung_nextkm)

	0.333 (S.L.cockpit_wischer_drehschalter)
	
	(L.S.Time) (S.L.cp_timer_minus)
	

	
{end}

'----------------------
'	Frame
'----------------------
{macro:cockpit_frame}
'Ьbertragen der Schalterstellungen:
	(L.L.cp_retarder_sw) (S.L.antrieb_retarder_sw)
	(L.L.cp_retarder_sw_direkt) (S.L.antrieb_retarder_sw_direkt)
	(L.L.cp_wischer_schnell_sw) (S.L.wiper_schnell_sw)
	(L.L.cp_wischer_einaus_sw) (S.L.wiper_einaus_sw)
	(L.L.cp_wischer_intervall_sw) (S.L.wiper_intervall_sw)
	(L.L.cp_wischer_wascher_sw) (S.L.wiper_wascher_sw)
	
	(L.L.AI) 
	{if}
		(L.L.AI_Engine) 0.5 >
		{if}	
			1 (S.L.selector_DNR) (S.L.cp_kluch_trans_mode) (S.L.cp_kluch_trans)
			4 (S.L.cp_kluch_trans_mode) 
			0.8 (S.L.cp_kluch_rot)
		{else}
			0 (S.L.selector_DNR) (S.L.cp_kluch_trans_mode) (S.L.cp_kluch_trans) 
			(S.L.cp_kluch_trans_mode) (S.L.cp_kluch_rot)
		{endif}
	{endif}	

	(M.L.cp_sound_frame)
	(M.L.tacho_frame)
	(M.L.uhr_frame)
	(M.L.drehzahlmesser_frame)
	(M.L.hupe_frame)
	(M.L.blinkerhebel_frame)
	(M.L.wischerhebel_frame)
	(M.L.wischer_drehschalter_frame)
	(M.L.oeldruck_frame)
	(M.L.tankuhr_frame)
	(M.L.cockpitlights_frame)
	(M.L.klimator_frame)
	(M.L.odometer_frame)
	(M.L.fahrertuer_frame) 
	(M.L.rollo_frame)
	(M.L.engine_thermometer_frame)
	(M.L.microphone_frame)
	(M.L.pressure_warning_needle_frame)
	(M.L.zentralschmierung_frame)
	(M.L.Thermometer_frame)
	(M.L.Odometr_display)
	(M.L.ampermetr_frame)
	(M.L.podsvetka_frame)
	(M.L.TEST_DISPLAY)
	(M.L.Termometr_comb)
	(M.L.timer_frame)
	(M.L.magnitola_frame)
	
	
	
{end}

{macro:cp_sound_frame}
	
'	(L.L.cp_sound_antirepeat_1) !
'	{if}		
'	(L.L.cp_gitara_rot1) 1 =
'	(L.L.cp_gitara_rot2) 0 = ||
'	0.5 = ||
'	0.8 = ||
'	1 = ||
'		{if}
'			(T.L.ev_schluessel_steck)
'			(T.L.ev_gitara)
'		{endif}
'		1 (S.L.cp_sound_antirepeat_1)
'	{endif}
	
'	(L.L.cp_schluessel_trans_lastmode) (L.L.cp_schluessel_trans_mode) = !
'	{if}
'		(T.L.ev_schluessel_steck)
'	{endif}
'	(L.L.cp_schluessel_trans_mode) (S.L.cp_schluessel_trans_lastmode)

'	Переключатель гитары
	(L.L.cp_gitara_rot_mode1) 
	(L.L.cp_gitara_rot_last) (L.L.cp_gitara_rot_mode2) = ! ||
	{if}
		(T.L.ev_gitara)
	{endif}
	(L.L.cp_gitara_rot_mode2) (S.L.cp_gitara_rot_last)
	
'	Переключатель аварийного выключателя
	(L.L.cp_avar_rot_mode_last) (L.L.cp_avar_rot_mode) = !
	{if}
		(T.L.ev_avar_stop)
	{endif}
	(L.L.cp_avar_rot_mode) (S.L.cp_avar_rot_mode_last)
	
	(L.L.cp_kluch_trans_lastmode) (L.L.cp_kluch_trans_mode) = !
	{if}
		(T.L.ev_key_insert)
'		(T.L.ev_keys)
	{endif}
	(L.L.cp_kluch_trans_mode) (S.L.cp_kluch_trans_lastmode)
	
	(L.L.cp_kluch_rot_lastmode) (L.L.cp_kluch_rot_mode) = !
	{if}
		(T.L.ev_key_rot)
	{endif}
	(L.L.cp_kluch_rot_mode) (S.L.cp_kluch_rot_lastmode)

{end}

'------------------------------
' Спидометр
'------------------------------
{macro:tacho_frame}
	(L.L.Velocity) (F.L.cockpit_tacholinie) (S.L.cockpit_tachowinkel)
{end}

{macro:uhr_frame}
	(L.S.Time) s0 60 / (S.L.cockpit_uhr_min) 12 / (S.L.cockpit_uhr_std)
	l0 trunc (S.L.cockpit_uhr_sek)
{end} 

{macro:drehzahlmesser_frame}
	(L.L.engine_n) 3000 270 / / (S.L.cockpit_drehzahlwinkel)
{end}


'------------------------------
' Громкость звукового сигнала
'------------------------------
{macro:hupe_frame}
	{if}
		(L.L.cockpit_hupe) 1 =
		{if}
			(L.L.cockpit_hupe_volume) 1 <
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * + (S.L.cockpit_hupe_volume)
			{else}
				1 (S.L.cockpit_hupe_volume)
			{endif}
		{else}
			(L.L.cockpit_hupe_volume) 0 >
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
			{else}
				0 (S.L.cockpit_hupe_volume)
			{endif}
		{endif}
	{else}
		(L.L.cockpit_hupe_volume) 0 >
		{if}
			(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
		{else}
			0 (S.L.cockpit_hupe_volume)
		{endif}
	{endif}	
	
{end}

{macro:blinkerhebel_frame}
	(L.L.lights_sw_blinker) 1 =
	{if}	
		-1 (S.L.cockpit_blinkerhebel)
	{else}
		(L.L.lights_sw_blinker) 2 =
		{if}
			1 (S.L.cockpit_blinkerhebel)
		{else}
			0 (S.L.cockpit_blinkerhebel)
		{endif}
	{endif}

'	Hebel-Animation fьr Fernlicht
	(L.L.lights_sw_fern)
	{if}	
		(L.L.cockpit_fernlichthebel) -1 = !
		{if}
			1 (S.L.cockpit_fernlichthebel)
		{endif}

		(L.L.cp_schluessel_rot) 0.8 >
		{if}
			-1 (S.L.cockpit_fernlichthebel)
		{endif}
	{else}
		0 (S.L.cockpit_fernlichthebel)
	{endif}


{end}

{macro:wischerhebel_frame}

	(L.L.cockpit_wischerhebel_lastmode) (L.L.cockpit_wischerhebel_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischerhebel_lastmode)
{end}

{macro:wischer_drehschalter_frame}

	(L.L.cockpit_wischer_drehschalter_lastmode) (L.L.cockpit_wischer_drehschalter_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter_lastmode)
{end}



{macro:cockpitlights_frame}

'	Stцrungsmelder


'	Batterie
	(L.L.engine_n) 400 < (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_batterie)

'	Tьrkontrolle|
	(L.L.Nothahn_1_sw) ||
	(L.L.Nothahn_2_sw) ||
	(L.L.Nothahn_3_sw) 

'	Geschwindigkeitswarnung
	(L.L.Velocity) 95 > (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_speedwarning)
	
'	Kinderwagenwunsch
	(L.L.door_kinderwagenwunsch) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_kinderwagenwunsch)

'	Kippschalter-Beleuchtung
	(L.L.cp_retarder_sw_direkt) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_retarder_direkt)

	(L.L.cp_retarder_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_retarder)

	(L.L.cp_licht_untenrechts_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_licht_untenrechts)

	(L.L.cp_licht_unterdeck_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_licht_unterdeck)

	(L.L.cp_licht_oberdeck_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_licht_oberdeck)

	(L.L.cp_wischer_schnell_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_schnell)

	(L.L.cp_wischer_einaus_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_einaus)

	(L.L.cp_wischer_intervall_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_intervall)
	
	(L.L.cp_wischer_wascher_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_wascher)

	(L.L.cp_heizluefter_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_heizluefter)
	
	(L.L.antrieb_getr_gangwahl) 7 = (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_gang3)
	
	(L.L.antrieb_getr_gangwahl) 1 = (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_gangN)

	(L.L.antrieb_getr_gangwahl) 0 = (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_gangR)

	(L.L.cp_motorkuehlung_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_motorkuehlung)

	(L.L.door_handsteuerung) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_tuer_handsteuerung)


' Индикаторы блока управления и диагностики двигателя и ГМП
'-------------------------------------	

'	Лампа критической ошибки
	(L.L.engine_failure_general) (L.L.elec_busbar_main_sw) &&
	(S.L.light_engine_general_error)

'	Лампа работы ASR	
	(L.L.engine_ASR_eingriff) (L.L.elec_busbar_main_sw) &&
	(S.L.light_ASR)
	
'	Лампа работы ABS	
	(L.L.bremse_ABS_eingriff) (L.L.elec_busbar_main_sw) &&
	(S.L.light_ABS)

'	Лампа оборотов двигателя 900 и 1000
	(L.L.tmb_CAT_rpm_polozhenie) 1 =
	(L.L.elec_busbar_main_sw) &&
	{if}
		(S.L.light_engine_rpm_900)
		0 (S.L.light_engine_rpm_1000)
	{else}
		(L.L.tmb_CAT_rpm_polozhenie) 2 =
		(L.L.elec_busbar_main_sw) &&
		{if}
			(S.L.light_engine_rpm_1000)
			0 (S.L.light_engine_rpm_900)
		{endif}
		
		(L.L.tmb_CAT_rpm_polozhenie) 0 =
		(L.L.elec_busbar_main_sw) &&
		{if}
			0 (S.L.light_engine_rpm_1000)
			0 (S.L.light_engine_rpm_900)
		{endif}
	{endif}
	
'	Лампа неисправности ГМП
	(L.L.antrieb_failure_general) (L.L.elec_busbar_main_sw) &&
	(S.L.light_GMP_general_error)
	
'	Лампа-индикатор работы системы гидрозамедлителя (ретардера)
	(L.L.antrieb_retarder) (L.L.cockpit_proverka2) ||
	(L.L.elec_busbar_main_sw) &&
	(S.L.light_antrieb_retarder)
	
'	Лампа-индикатор низкого давления в 1-ом контуре
	(L.L.bremse_p_tank01) 10000 < 
	(L.L.cockpit_proverka2) ||
	(L.L.elec_busbar_main_sw) &&
	(S.L.light_tank1)
	
'	Лампа-индикатор низкого давления в 2-ом контуре
	(L.L.bremse_p_tank02) 10000 < 
	(L.L.cockpit_proverka2) ||
	(L.L.elec_busbar_main_sw) &&
	(S.L.light_tank2)
	
'	Лампа-индикатор низкого давления в 3-ем контуре
	(L.L.bremse_p_tank03) 10000 < 
	(L.L.cockpit_proverka2) ||
	(L.L.elec_busbar_main_sw) &&
	(S.L.light_tank3)
	
'	Лампа-индикатор низкого давления в 4-ом контуре
	(L.L.bremse_p_tank04) 10000 < 
	(L.L.cockpit_proverka2) ||
	(L.L.elec_busbar_main_sw) &&
	(S.L.light_tank4)
	
'	Лампа-индикатор включения стояночного тормоза (мигает при включении)
	(L.L.bremse_feststell)
	(L.L.cockpit_proverka2) ||
	(L.L.elec_busbar_main) &&
	{if}
		(L.S.Timegap) (L.L.light_feststell_runtime) + (S.L.light_feststell_runtime)
		(L.L.light_feststell_runtime) (L.L.light_feststell_timegap) >
		{if}
			(L.L.light_feststell) ! (S.L.light_feststell)
			{if}
				(C.L.lights_blinkertime_on)
			{else}
				(C.L.lights_blinkertime_off)
			{endif}
			(S.L.light_feststell_timegap)
			0 (S.L.light_feststell_runtime)
		{endif}
	{else}
		0 (S.L.light_feststell) (S.L.light_feststell_runtime)
	{endif}
	
'	Лампа-индикатор блокировки заднего хода (загорается когда включена передача R)
	(L.L.antrieb_rear_blocking) 1 =
	(L.L.antrieb_getr_gangvorwahl) 0 = &&
	(L.L.elec_busbar_main_sw) &&
	(S.L.light_rear_blocking)

'Лампа-индикатор включения дальнего света
	(L.L.lights_fern) 
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_fahrerlicht)	
	
'Лампа-индикатор включения ближнего света
	(L.L.lights_abbl) 
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_abbl)

'Лампа-индикатор включения заднего противотуманного фонаря
	(L.L.lights_nebelschluss_rear) 
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_PT_rear)

'Лампа-индикатор включения задней передачи и фонаря заднего хода
	(L.L.lights_rueckfahr) 
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_rear)

'Лампа-индикатор включения поворотников
	(L.L.lights_blinker_l) 
	(L.L.lights_blinker_r) ||
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_blinkers)	
	
'Лампа-индиктор включения обогрева зеркал
	(L.L.cp_spiegelheizung_sw) 
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_spiegelheizung)
	
'Лампа-индикатор аварийного выключателя
	(L.L.cp_avar_rot) 0 > 
	(L.L.lights_warnblinkgeber) &&
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_avar_blinkers)
	
'Лампа-индиктор включения освещения маршрутоуказателей
	(L.L.cp_marshrutniki_podsvetka) 
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.light_marshrutniki)
	
'Лампа общей неисправности
	(L.L.antrieb_failure_general)
	(L.L.engine_failure_general) ||
	(L.L.cockpit_oeldruck) 0.8 < ||
	(L.L.engine_tank_content) 30 < ||
	(L.L.engine_temperature) 98 > ||
	(L.L.elec_V_battery) 0.8 < ||
	(L.L.bremse_p_tank01) 570000 < ||
	(L.L.bremse_p_tank02) 570000 < ||
	(L.L.bremse_p_tank03) 570000 < ||
	(L.L.bremse_p_tank04) 570000 < ||
	(L.L.cockpit_proverka1) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_masterfailure)
	
'Лампа-индиктор пустая 
	(L.L.cockpit_proverka1)
	(L.L.elec_busbar_main) &&
	(S.L.light_dummy)
	
'Лампа работы жидкостного подогревателя и циркуляционного насоса
	(L.L.EFU_running) (S.L.light_EFU)
	
'Лампа работы циркуляционного насоса
	(L.L.CN_running)
	(L.L.elec_busbar_main) &&
	(S.L.light_CN)
{end}

'----------------------------------------
' Давление масла в системе смазки двигателя
'----------------------------------------
{macro:oeldruck_frame}
	(L.L.engine_n) (F.L.cockpit_oeldruck) (F.L.cockpit_oelscale) s0

	(L.L.elec_priborka_voltage) 1 =
	{if}
		(L.L.cockpit_oeldruck) 0.8 <
		{if}
			1 (S.L.light_maslo)
		{else}
			0 (S.L.light_maslo)
		{endif}
	{else}
		0 s0
		0 (S.L.light_maslo)
	{endif}

	(L.L.cockpit_oeldruck) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_oeldruck)
{end}

'----------------------------------------
' Уровень топлива
'----------------------------------------
{macro:tankuhr_frame}
	(L.L.engine_tank_content) s0

	(L.L.elec_priborka_voltage) 1 =
	{if}
		(L.L.engine_tank_content) 30 <
		{if}
			1 (S.L.light_toplivo)
		{else}
			0 (S.L.light_toplivo)
		{endif}
	{else}
		0 s0
		0 (S.L.light_toplivo)
	{endif}

	(L.L.cockpit_tankuhr) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_tankuhr)
{end}

'----------------------------------------
' Температура охдаждающей жидкости двигателя
'----------------------------------------
{macro:engine_thermometer_frame}
	(L.L.elec_priborka_voltage) 1 =
	{if}
		(L.L.engine_temperature) 98 >
		{if}
			1 (S.L.light_temperature)
		{else}
			0 (S.L.light_temperature)
		{endif}
		(L.L.engine_temperature) (F.L.cockpit_engine_temperature) s0
	{else}
		0 s0
		0 (S.L.light_temperature)
	{endif}

	(L.L.cockpit_motortemperaturwinkel) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_motortemperaturwinkel)
{end}

'----------------------------------------
' Напряжение на аккумуляторных батареях
'----------------------------------------
{macro:ampermetr_frame}
	(L.L.elec_priborka_voltage) 1 =
	{if}
		(L.L.elec_V_battery) 0.8 <
		{if}
			1 (S.L.light_ampermetr)
		{else}
			0 (S.L.light_ampermetr)
		{endif}
		(L.L.elec_V_battery) (F.L.cockpit_ampermetr) s0
	{else}
		0 s0
		0 (S.L.light_ampermetr)
	{endif}

	(L.L.cockpit_ampermetr) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_ampermetr)
{end}	

'----------------------------------------
' Подсветка приборов
'----------------------------------------
{macro:podsvetka_frame}
		(L.L.elec_busbar_main)
		(L.L.cp_podsvetka_trans) &&
		{if}
			1 (S.L.light_podsvetka)
		{else} 
			0 (S.L.light_podsvetka)
		{endif}
{end}

'----------------------------------------
' Звук кнопок\переключателей\тумблеров
'----------------------------------------
{macro:kippschaltersound}
	l1
	{if}
		(T.L.ev_kippschalter_ein)
	{else}
		(T.L.ev_kippschalter_aus)
	{endif}	
{end}

'----------------------------------------
' Звук люков
'----------------------------------------
{macro:klappfenstersound}
	l1
	{if}
		(T.L.ev_klappfenster_opn)
	{else}
		(T.L.ev_klappfenster_cls)
	{endif}	
{end}

'----------------------------------------
' Управление вентиляторами отопителя
'----------------------------------------
{macro:klimator_frame}

'Frontheizgerдt:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_klimator_sw) s1
	{else}
		0 s1
	{endif}

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_klimator_RPM) > 
	{if}
		1.5 s0
	{else}
		0.5 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_klimator_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_klimator_RPM) + (S.L.cp_klimator_RPM)


'Raumheizgerдte:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_heizluefter_sw) s1
	{else}
		0 s1
	{endif}

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_cabinheater_RPM) > 
	{if}
		6 s0
	{else}
		1.0 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_cabinheater_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_cabinheater_RPM) + (S.L.cp_cabinheater_RPM)




{end}

'----------------------------------------
' Расчет плавного движения стрелки
'----------------------------------------
{macro:traegheit}

'Simuliert trдges Verhalten (exponentiell) Имитация движения стрелки

'Ladekonventionen: Загрузка переменных:

'	Sollwert Заданная величина		l0
'	Istwert	Полученная величина		l1
'	Konstante Anlauf Начало движения	l2 (Einheiten/s)
'	Konstante Ablauf Окончание движения	l3 (Einheiten/s)

'Anlauf oder Auslauf?
	l0 l1 > 
	{if}
		l2 (L.S.Timegap) * 1 min -1 max s4
	{else}
		l3 (L.S.Timegap) * 1 min -1 max s4
	{endif}


'Sollwert:
	l0
'Istwert:
	l1
'Beschleunigung: Ускорение:
	- l4 *
'Addition zum Istwert: Добавить к предыдущему значению
	l1 + s1
{end}

'----------------------------------------
' Механический одометр
'----------------------------------------
{macro:odometer_frame}
	(L.L.kmcounter_km) (L.L.kmcounter_m) 1000 / + 10 *
	(S.L.cp_odometer_01)

	(L.L.cp_odometer_01) 10 / trunc 
	(L.L.cp_odometer_01) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_1)

	(L.L.cp_odometer_1) 10 / trunc 
	(L.L.cp_odometer_1) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_10)

	(L.L.cp_odometer_10) 10 / trunc 
	(L.L.cp_odometer_10) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_100)

	(L.L.cp_odometer_100) 10 / trunc 
	(L.L.cp_odometer_100) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_1000)

	(L.L.cp_odometer_1000) 10 / trunc 
	(L.L.cp_odometer_1000) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_10000)

	(L.L.cp_odometer_10000) 10 / trunc 
	(L.L.cp_odometer_10000) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_100000)


	(L.L.kmcounter_m) 100 / (S.L.cp_odometer_01)
{end}


{macro:fahrertuer_frame}

	(L.L.cp_fahrertuer_dragged) !
	{if}
		(L.L.cp_fahrertuer_pos) (L.S.Timegap) (L.L.cp_fahrertuer_speed) * + (S.L.cp_fahrertuer_pos)

		(L.L.cp_fahrertuer_pos) 1 >
		{if}
			1 (S.L.cp_fahrertuer_pos)
			(L.L.cp_fahrertuer_speed) /-/ 0.7 * (S.L.cp_fahrertuer_speed)
		{endif}
		(L.L.cp_fahrertuer_pos) 0 <
		{if}
			0 (S.L.cp_fahrertuer_speed) (S.L.cp_fahrertuer_pos)
		{endif}

		(L.L.cp_fahrertuer_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_fahrertuer_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_fahrertuer_globalangle) * * + (S.L.cp_fahrertuer_speed)
		{endif}
	
		(L.L.cp_fahrertuer_speed) s0 (S.L.cp_fahrertuer_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer_speed)
		{endif}


		(L.L.cp_fahrertuer_speed) 0 > (L.L.cp_fahrertuer_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_speed) 0 < (L.L.cp_fahrertuer_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_pos) 0 > (L.L.cp_fahrertuer_open) ! &&
	{if}
		(T.L.ev_fahrertuer_auf)
		1 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 0 = (L.L.cp_fahrertuer_open) &&
	{if}
		(T.L.ev_fahrertuer_zu)
		0 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
	

{end}

'----------------------------------------
' Солнечнозащитная шторка
'----------------------------------------
{macro:rollo_frame}
	(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) max (S.L.cp_rollo_rastpos)

	(L.L.cp_rollo_dragged) !
	{if}
		(L.L.cp_rollo_retract)
		{if}
			(L.L.cp_rollo_speed) (L.S.Timegap) (L.L.cp_rollo_pos) 14 * * - (S.L.cp_rollo_speed)
			(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
					
		{else}
			(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) < 
			{if}
				(L.L.cp_rollo_speed) (L.S.Timegap) 14 * + (S.L.cp_rollo_speed)
				(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (L.L.cp_rollo_rastpos) min (S.L.cp_rollo_pos)
			{else}
				0 (S.L.cp_rollo_speed)
			{endif}
		{endif}

		(L.L.cp_rollo_pos) 1 >
		{if}
			1 (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
		{else}
			(L.L.cp_rollo_pos) 0 <
			{if}
			0 (S.L.cp_rollo_pos) (S.L.cp_rollo_retract) (S.L.cp_rollo_rastpos)
			{endif}
		{endif}

	{endif}
{end}



{macro:microphone_frame}

	(L.L.Clutch) 0.2 > (L.L.cp_microphone_sw) ||
	(L.L.elec_busbar_main) && s0
	(L.L.Snd_Microphone) s1


	l0 l1 ! &&
	{if}
		(T.L.micro_lautsprecherknack_start)
	{endif}

	l0 ! l1 &&
	{if}
		(T.L.micro_lautsprecherknack_end)
	{endif}


	l0 (S.L.Snd_Microphone)
{end}


{macro:pressure_warning_needle_frame}

	(L.L.bremse_p_Tank01) (L.L.bremse_p_Tank02) + 2 / (S.L.cockpit_warndruck) (F.L.cockpit_warndruck) (S.L.cockpit_warndruckwinkel)

{end}

{macro:zentralschmierung_frame}

	(L.L.cp_zentralschmierung_nextkm) (L.L.velocity) 3600 / (L.S.Timegap) * + (S.L.cp_zentralschmierung_nextkm)
	(C.L.cockpit_zentralschmierung_dist) >
	(L.L.cp_zentralschmierung_runtime) (C.L.cockpit_zentralschmierung_maxtime) < &&
	{if}
		1 (S.L.cockpit_light_zentralschmierung)
		(L.L.cp_zentralschmierung_runtime) (L.S.Timegap) + (S.L.cp_zentralschmierung_runtime)
	{else}
		(L.L.cockpit_light_zentralschmierung)
		{if}
			0 (S.L.cp_zentralschmierung_nextkm)
		{endif}
		0 (S.L.cockpit_light_zentralschmierung) (S.L.cp_zentralschmierung_runtime)
	{endif}	

{end}

'----------------------------------------
' Электронный термометр
'----------------------------------------
{macro:Thermometer_frame}

	(L.L.Cabinair_Temp) s0 trunc " 3" $IntToStrEnh "." $+ 
	l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ "C" $+
	(S.$.cockpit_temperatur)
{end}

'-------------------------------------------
' Дисплей одометра, ибиса, термометра
'-------------------------------------------
{macro:Odometr_display}
	(L.L.elec_priborka_voltage) 1 =
	{if}
'		Вывод общего пробега
		(L.L.kmcounter_km) trunc " 6" $IntToStrEnh (S.$.odometr_disp1)
		
'		Расчет суточного пробега в км
		(L.L.kmcounter_km) (L.L.odometer_kmlast) - (S.L.odometr_sutki)

'		Расчет суточного пробега в метрах
		(L.L.kmcounter_m) (L.L.odometer_mlast) - 100 / (S.L.odometr_sutki_metr)
		
'		Вывод суточного пробега
		(L.L.odometr_sutki) trunc " 4" $IntToStrEnh 
		"." $+
		(L.L.odometr_sutki_metr) trunc " 1" $IntToStrEnh $+
		(S.$.odometr_disp2)

'		Если суточный пробег будет больше 9999 км, то он автоматически сбросится (защита от дурака)		
		(L.L.odometr_sutki) 9999 >=
		{if}
			(L.L.kmcounter_km) (S.L.odometer_kmlast)
			(L.L.kmcounter_m) (S.L.odometer_mlast)
			0 (S.L.odometr_sutki) (S.L.odometr_sutki_metr)
		{endif}
		
	{else}
		" " $ (S.$.odometr_disp1)
		" " $ (S.$.odometr_disp2)
	{endif}
{end}

{macro:TEST_DISPLAY}
'	(L.L.autoinform_stop_timer) $IntToStr (S.$.test)
	">ул. Врача Михайлова   15:31" "@" $+
	">ул. Деева   15:33" $+ "@" $+
	"=============================" $+ "@" $+
	"ОТСТАВАНИЕ: 0.5 мин." $+ (S.$.test)
{end}

{macro:Termometr_comb}
'	Индикатор даты

'	Вычисляет день недели
	(L.S.DayOfYear) 
	(L.S.Year) 365.25 *
	+ 7 % 
	(S.L.Day_of_Week)
	
'	В зависимости от дня недели, на экран выводится число (L.S.Day), месяц (L.S.Month) и соответствующий код
'	дня недели 	" R" - четверг, " T" - пятница, " Y" - суббота, " U" - воскресенье, " Q" - понедельник,
'	" W" - вторник, " E" - среда
	
	(L.S.Day) $IntToStr " " $+ (L.S.Month) $IntToStr $+ 
	
	(L.L.Day_of_Week) 0 =
	{if}
		" R" $+ (S.$.Temp_date)
	{else}
		(L.L.Day_of_Week) 1 =
		{if}
			" T" $+ (S.$.Temp_date)
		{else}
			(L.L.Day_of_Week) 2 =
			{if}
				" Y" $+ (S.$.Temp_date)
			{else}
				(L.L.Day_of_Week) 3 =
				{if}
					" U" $+ (S.$.Temp_date)
				{else}
					(L.L.Day_of_Week) 4 =
					{if}
						" Q" $+ (S.$.Temp_date)
					{else}
						(L.L.Day_of_Week) 5 =
						{if}
							" W" $+ (S.$.Temp_date)
						{else}
							" E" $+ (S.$.Temp_date)
						{endif}
					{endif}
				{endif}
			{endif}
		{endif}
	{endif}

'	Цифровые часы	
	(L.S.Time) 3600 / trunc " 2" s0
	(L.S.Time) 60 / l0 60 * - s1 
	
	l0 10 <
	{if}
		"0" l0 $IntToStr $+
	{else}
		l0 $IntToStr
	{endif}
	
	l1 10 <
	{if}
		":0" $+ l1 $IntToStr $+
	{else}
		":" $+ l1 $IntToStr $+
	{endif}
	
	(S.$.Temp_time)	

'	Температура салона
	(L.L.Cabinair_Temp) -10 < 
	(L.L.Cabinair_Temp) 100 > ||
	{if}
		(L.L.Cabinair_Temp) $IntToStr (S.$.Temp_inner)
	{else}
		(L.L.Cabinair_Temp) 10 > 
		(L.L.Cabinair_Temp) -1 < ||
		{if}
			" " (L.L.Cabinair_Temp) $IntToStr $+ (S.$.Temp_inner)
		{else}
			(L.L.Cabinair_Temp) 0 < ||
			{if}
				" -" (L.L.Cabinair_Temp) $IntToStr $+ (S.$.Temp_inner)
			{else}
				"  " (L.L.Cabinair_Temp) $IntToStr $+ (S.$.Temp_inner)
			{endif}
		{endif}
	{endif}
	
	(L.L.Cabinair_Temp) abs (L.L.Cabinair_Temp) abs trunc - 10 * trunc " 1" $IntToStr (S.$.Temp_inner_ostatok)
	
'	Температура улицы
	(L.S.Weather_Temperature) -10 < 
	(L.S.Weather_Temperature) 100 > ||
	{if}
		(L.S.Weather_Temperature) $IntToStr (S.$.Temp_out)
	{else}
		(L.S.Weather_Temperature) 10 > 
		(L.S.Weather_Temperature) -1 < ||
		{if}
			" " (L.S.Weather_Temperature) $IntToStr $+ (S.$.Temp_out)
		{else}
			(L.S.Weather_Temperature) 0 < ||
			{if}
				" -" (L.S.Weather_Temperature) $IntToStr $+ (S.$.Temp_out)
			{else}
				"  " (L.S.Weather_Temperature) $IntToStr $+ (S.$.Temp_out)
			{endif}
		{endif}
	{endif}
	
	(L.S.Weather_Temperature) abs (L.S.Weather_Temperature) abs trunc - 10 * trunc " 1" $IntToStr (S.$.Temp_out_ostatok)
	
{end}


{macro:timer_frame}
'	Цифровые часы
	(L.L.cp_timer_mode) 1 =
	{if}
		(L.S.Time) 3600 / trunc " 2" s0
		(L.S.Time) 60 / l0 60 * - s1
		(L.S.Time) 60 % s2
	{else}
		(L.L.cp_timer_mode) 0 =
		{if}
			(L.S.Time) (L.L.cp_timer_minus) - 3600 / trunc " 2" s0
			(L.S.Time) (L.L.cp_timer_minus) - 60 / l0 60 * - s1
			(L.S.Time) (L.L.cp_timer_minus) - 60 % s2
		{endif}
	{endif}

	l0 10 <
	{if}
		"0" l0 $IntToStr $+
	{else}
		l0 $IntToStr
	{endif}
	
	l1 10 <
	{if}
		":0" $+ l1 $IntToStr $+
	{else}
		":" $+ l1 $IntToStr $+
	{endif}
	
	l2 10 <
	{if}
		":0" $+ l2 $IntToStr $+
	{else}
		":" $+ l2 $IntToStr $+
	{endif}
	
	(S.$.Timer)
	
	(L.L.cp_timer_mode) 0 =
	l0 23 > &&
	l1 59 > &&
	l2 59 > &&
	{if}
		(L.S.Time) (S.L.cp_timer_minus)
	{endif}

{end}

{macro:magnitola_frame}
	(L.L.elec_busbar_main) &&
	{if}
		1 (S.L.cp_magnitola_podsvetka) (S.L.Snd_Radio)
	{else}
		0 (S.L.cp_magnitola_podsvetka) (S.L.Snd_Radio)
	{endif}
{end}